package com.hnkywl.sts.action.cwgl;

import com.hnkywl.sts.entity.organ.Nbgs;
import com.hnkywl.sts.entity.sfgl.Sfk;
import com.hnkywl.sts.entity.sys.Gncz;
import com.hnkywl.sts.entity.sys.Yg;
import com.hnkywl.sts.service.cwgl.HzdrService;
import com.hnkywl.sts.service.cwgl.SkdrService;
import com.hnkywl.sts.service.organ.GsjgService;
import com.hnkywl.sts.service.sys.GnczService;
import com.hnkywl.sts.service.sys.YgService;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Actions;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Created by HL on 2015/9/24.
 */
@Namespace("/cwgl/hzdr")
public class HzdrAction extends SimpleActionSupport {
    private String sysDate;
    private Date sysdate = new Date();
    private HzdrService hzdrService;
    private GsjgService gsjgService;
    private Date skshEnd;
    private Date skshStart;
    private Long skshId;
    private String zt;
    //单据号码
    private String bm;
    //申报公司机构名称
    private String sbgs;
    //申报公司机构Id
    private Long sbgsId;
    //分页组件 起始位置
    private int page;
    //分页组件 页面大小
    private int rows = 10;
    //收付款实例
    private Sfk hzdr;
    private String gldwMc;

    private Long gldwId;
    private String skr;
    private List<Gncz> gnczList;
    private GnczService gnczService;



    @Action("hzdrList")
    public void skdrList() {
        this.renderJson(this.hzdrService.findAllHzdrdr(skshStart, skshEnd, bm, sbgs, sbgsId, gldwMc, zt, skr, page, rows));
    }

    @Actions({@Action("hzdr_content"), @Action("hzdr_detail")})
    public String skshContent() {
        Yg yg = YgService.getCurrentYg();
        Long gsId = YgService.getCurrentYgGsId();
        Long zggsId = YgService.getCurrentYgZgGsId();
        //进入update页面
        if (skshId != null) {
            hzdr = hzdrService.findhzdrDetail(skshId);
        } else {
            hzdr = new Sfk();
            hzdr.setSbr(yg);
            hzdr.setSbgs((Nbgs) gsjgService.findGsjgDetail(zggsId));
        }
        return SUCCESS;
    }

    @Action("hzdr")
    public String sksh() {
        SimpleDateFormat simple = new SimpleDateFormat("yyyy-MM-dd");
        sysDate = simple.format(new Date());
        gnczList = gnczService.findGnczByJsAndUrl(request.getServletPath());
        return SUCCESS;
    }



    //==========================================


    public String getSysDate() {
        return sysDate;
    }

    public void setSysDate(String sysDate) {
        this.sysDate = sysDate;
    }

    public Date getSysdate() {
        return sysdate;
    }

    public void setSysdate(Date sysdate) {
        this.sysdate = sysdate;
    }

    public Date getSkshEnd() {
        return skshEnd;
    }

    public void setSkshEnd(Date skshEnd) {
        this.skshEnd = skshEnd;
    }

    public Date getSkshStart() {
        return skshStart;
    }

    public void setSkshStart(Date skshStart) {
        this.skshStart = skshStart;
    }

    public Long getSkshId() {
        return skshId;
    }

    public void setSkshId(Long skshId) {
        this.skshId = skshId;
    }

    public String getZt() {
        return zt;
    }

    public void setZt(String zt) {
        this.zt = zt;
    }

    public String getBm() {
        return bm;
    }

    public void setBm(String bm) {
        this.bm = bm;
    }

    public String getSbgs() {
        return sbgs;
    }

    public void setSbgs(String sbgs) {
        this.sbgs = sbgs;
    }

    public Long getSbgsId() {
        return sbgsId;
    }

    public void setSbgsId(Long sbgsId) {
        this.sbgsId = sbgsId;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public Sfk getHzdr() {
        return hzdr;
    }

    public void setHzdr(Sfk hzdr) {
        this.hzdr = hzdr;
    }

    public String getGldwMc() {
        return gldwMc;
    }

    public void setGldwMc(String gldwMc) {
        this.gldwMc = gldwMc;
    }

    public Long getGldwId() {
        return gldwId;
    }

    public void setGldwId(Long gldwId) {
        this.gldwId = gldwId;
    }

    public String getSkr() {
        return skr;
    }

    public void setSkr(String skr) {
        this.skr = skr;
    }

    public List<Gncz> getGnczList() {
        return gnczList;
    }

    public void setGnczList(List<Gncz> gnczList) {
        this.gnczList = gnczList;
    }


    @Autowired
    public void setHzdrService(HzdrService hzdrService) {
        this.hzdrService = hzdrService;
    }

    @Autowired
    public void setGnczService(GnczService gnczService) {
        this.gnczService = gnczService;
    }
    @Autowired
    public void setGsjgService(GsjgService gsjgService) {
        this.gsjgService = gsjgService;
    }
}
